package com.fairytask.managers
{
	import com.fairytask.data.Modulator;
	import com.fairytask.data.ViewObject;
	import com.fairytask.engine.components.ToolTips;
	import com.fairytask.engine.define.PackageType;
	import com.fairytask.resource.StaticIni;
	
	import flash.display.Sprite;
	import flash.geom.Point;
	import flash.text.TextField;
	
	public class TipsManage
	{
		//数据与绑定
		private var _model								:Modulator;
		private var _bindManager						:BindManager;
		private static var  _dataEquip				:Array=[];
		private static var bg_mc						:Sprite=new Sprite();
		private static var txt						:TextField=new TextField();
		private static var _self						:TipsManage;
		public function TipsManage()
		{
			_model=Modulator.instance;
			_bindManager=BindManager.instance;
			init();
			initBind();
		}
		public static function getInstance():TipsManage
		{
			if(_self == null)
			{
				_self	=	new TipsManage();
			}
			return _self;
		}
		private function init():void
		{
		}
		/**
		 *初始化绑定 
		 * 
		 */		
		private function initBind():void
		{
			//_bindManager.BindView(_model.scene, ViewDefine.VIEWPORT_EQUIP, onAddEquip, onDelEquip);
		}
		/**
		 *添加人物装备 
		 * @param key
		 * @param val
		 * @param data
		 * 
		 */		
		private function onAddEquip(key:String, val:ViewObject, data:Object):void
		{
			var equipType:int=int(StaticIni.getIniVar(val.GetPropertiesEx("ConfigID"),"EquipType"));
			_dataEquip[equipType]=val;
		}
		/**
		 *删除人物装备 
		 * @param key
		 * @param val
		 * @param data
		 * 
		 */		
		private function onDelEquip(key:String, val:ViewObject, data:Object):void
		{
			var equipType:int=int(StaticIni.getIniVar(val.GetPropertiesEx("ConfigID"),"EquipType"));
			_dataEquip[equipType]=null;
		}
		/**
		 * 用普通文字显示tips
		 * @param str	要显示的字符串
		 * 
		 */		
		public static function showTips(str:String):void
		{
			ToolTips.ShowInfo(str,ToolTips.TxtStyleAuto,-1,true);
		}
		/**
		 * 显示技能tips
		 * @param configID	技能的configID
		 * 
		 */		
		public static function showSkillTips(configID:uint):void
		{
			//ToolTips.ShowInfo(new SkillTips().getStr(configID),ToolTips.TxtStyleFixed);
		}
		/**
		 * 显示命格tips
		 * @param configID	技能的configID
		 * 
		 */		
		public static function showChartTips(configID:int):void
		{
			ToolTips.ShowInfo(StaticIni.getSwfLangStr(StaticIni.getIniVar(configID,"DescribeID")),ToolTips.TxtStyleAuto,-1,true);
		}
		/**
		 * 对比装备 
		 * @param itemType
		 * @param configID
		 * @param data
		 * 
		 */		
		public static function showCompareEquip(itemType:uint,configID:uint,_data:ViewObject):void
		{
			var equipType:int=int(StaticIni.getIniVar(String(configID),"EquipType"));
			var iconId		:int	=	int(StaticIni.getIniVar(String(configID),"Icon"));
			//当前装备
			if(_dataEquip[equipType]!=null)
			{
				//ToolTips.ShowInfo(new ItemMaxTips().getStr(configID,_data),ToolTips.TxtStyleFixed,iconId,false,true,null);
				
				var compareId		:int	=	int(StaticIni.getIniVar(_dataEquip[equipType].GetPropertiesEx("ConfigID"),"Icon"));
				if(compareId	!=	0)
				{
//					ToolTips.ShowContrastInfo(StaticIni.getSwfLangStr("1000000318")+"<br/>"+
//						new ItemMaxTips().getStr(_dataEquip[equipType].GetPropertiesEx("ConfigID"),_dataEquip[equipType]),compareId,ToolTips.TxtStyleFixed);
				}
			}
			else
			{
				TipsManage.ShowItemMaxTips(configID,_data);
			}
		}
		/**
		 *显示世界地图 
		 * 
		 */		
		public static function showWorldMap(mapId:String):void
		{
			//ToolTips.ShowInfo(new MapTips().getStr(mapId),ToolTips.TxtStyleAuto);
		}
		/**
		 * 显示Bufftips
		 * @param configID	技能的configID
		 * 
		 */		
		public static function showBufferTips(configID:String,curCount:String, buffList:Array=null):void
		{
			//ToolTips.ShowInfo(new BufferTips().getStr(configID,curCount,buffList),ToolTips.TxtStyleAuto);
		}
		/**
		 * 现实简单物品的tips
		 * @param configID	物品的configID
		 * 
		 */	
		public static function ShowItemTips(configID:uint,isInShop:Boolean=false,isFollow:Boolean=true,stagePoint:Point=null):void
		{		
			var icon	:int	=	int(StaticIni.getIniVar(configID,"Icon"));
			//ToolTips.ShowInfo(new ItemTips().getStr(configID,isInShop),ToolTips.TxtStyleFixed,icon,false,isFollow,stagePoint);
		}
		/**
		 * 现实简单物品的tips
		 * @param configID	物品的configID
		 * 
		 */		
		public static function ShowItemTipsWithBuyPrice(configID:uint,captitalType:int,price:int,castleStatus:int):void
		{		
			var		itemObj:Object	=	StaticIni.getIniObj(String(configID));
			var		part1:String	=	"";
			var		part2:String	=	"<br>";
			
			if(itemObj["EquipType"])
			{
				//part1	=	new ItemMaxTips().getStr(configID,itemObj["MaxHardiness"]);
			}else
			{
				//part1	=	new ItemTips().getStrNoPrice(configID);
			}
			part2 = part2.concat(StaticIni.getSwfLangStr("UIStr_1000312"));
			part2 = part2.concat(String(price));			
			part2 =	part2.concat(StaticIni.getSwfLangStr("Tips_CapitalType"+captitalType)+"<br>");
			
			//自己城堡地位大于要求
			if(castleStatus != 0 )
			{
				var castleStatueTip:String = StaticIni.getSwfLangStrVar("UIStr_1000580",[StaticIni.getSwfLangStr("CastleStatus_"+castleStatus)]) +"<br>";
				part2 = part2.concat(castleStatueTip);
			}
			
			ToolTips.ShowInfo(part1+part2,ToolTips.TxtStyleFixed);
		}
		/**
		 * 显示装备物品的tips
		 * @param configID	套装物品的configID
		 * @param itemHard	耐久
		 * @param currentConfigIdArr	身上装备的configID数组
		 * 
		 */		
		public static function ShowItemMaxTips(configID:uint,_data:ViewObject=null,isInShop:Boolean=false,isFollow:Boolean=true,stagePosition:Point=null,isSelf:Boolean=true,isReadRecord:Boolean=true):void
		{
			var icon	:int	=	int(StaticIni.getIniVar(configID,"Icon"));
			//TODO
			//ToolTips.ShowInfo(new ItemMaxTips().getStr(configID,_data,isInShop,isSelf,isReadRecord),ToolTips.TxtStyleFixed,icon,false,isFollow,stagePosition);
		}
		
		/**
		 * NPC tips 
		 * @param descID 描述ID
		 * @param level 等级
		 * @param bossLevel boss级别 普通 0 ，boss，稀有
		 * 
		 */
		public static function ShowNpcTips(descID:String,level:String,bossLevel:uint):void
		{			
			//ToolTips.ShowInfo(NpcTips.getStr(descID,level,bossLevel),ToolTips.TxtStyleAuto);
		}
		
		/**
		 * 	快捷技能栏TIPS
		 * @param skillItemID
		 * 
		 */		
		public static function skillShortTips(skillItemID:int,iconId:int):void
		{
			//ToolTips.ShowInfo(new SkillShortCutTips().getString(skillItemID.toString()),ToolTips.TxtStyleFixed,iconId);	
		}
		
		/**
		 * 帮派技能Tips 
		 * 
		 */		
		public static function unionSkillTips(skillID:uint,iconId:uint):void
		{
			//ToolTips.ShowInfo(new UnionSkillTips().getString(skillID),ToolTips.TxtStyleFixed,iconId);
		}
		
		/**
		 * 宠物技能TIPS
		 * @param skillItemID
		 * 
		 */		
		public static function petSkillTips(skillItemID:int,iconId:int):void
		{
			//ToolTips.ShowInfo(new PetSkillTips().getString(skillItemID.toString()),ToolTips.TxtStyleFixed,iconId);	
		}
		
		/**
		 * 宠物Tips 
		 * @param configID
		 * @param _data
		 * @param isInShop
		 * @param isFollow
		 * @param stagePosition
		 * 
		 */
		public static function petEggTips(configID:uint,_data:ViewObject=null,isInShop:Boolean=false,isFollow:Boolean=true,stagePosition:Point=null,isShowEgg:Boolean=true):void
		{
			var icon	:int	=	int(StaticIni.getIniVar(configID,"Icon"));
			if(isInShop)
			{
				//ToolTips.ShowInfo(new ItemTips().getStr(configID,isInShop),ToolTips.TxtStyleFixed,icon,false,isFollow,stagePosition);
			}
			else
			{
				if(isShowEgg)
				{
					if(null==_data)
					{
						return;
					}
					//var eggTips:PetEggTips = PetEggTips.getInstance();
					//eggTips.setData(configID,_data);
					//TODO
					//ToolTips.ShowEggInfo(eggTips as Sprite,-1,true,isFollow,stagePosition);
				}
				else
				{
					//ToolTips.ShowInfo(new ItemTips().getStr(configID,isInShop),ToolTips.TxtStyleFixed,icon,false,isFollow,stagePosition);
				}
			}
			
		}
		
		/**
		 *所有的tips分类
		 * @param isShowEgg 宠物蛋是否显示完整tips
		 *  
		 */
		public static function ShowAllItemsTips(itemType:int,configID:uint,_data:ViewObject=null,contrast:Boolean=false,isInShop:Boolean=false,isFollow:Boolean=true,stagePosition:Point=null,isSelf:Boolean=true,isReadRecord:Boolean=true,isShowEgg:Boolean = true):void
		{
			switch (itemType)
			{
				/**材料---1*/
				case PackageType.STUFF:
				/**种子---2*/
				case PackageType.SEED:				
				/**商品---3*/
				case PackageType.COMMODITY:				
				/**宝石---4*/
				case PackageType.GEM:				
				/**药品---5*/
				case PackageType.LEECHDOM:				
				/**食物---6*/
				case PackageType.FOOD:				
				/**暗器---7*/
				case PackageType.GUN:				
				/**配方---8*/
				case PackageType.SCENOGRAPHY:				
				/**转轴---9*/
				case PackageType.SPIALE	:				
				/**任务---10*/
				case PackageType.ROLE:				
				/**垃圾---13*/
				case PackageType.TRASH:				
				/**14 宠物开格道具*/ 
				case PackageType.PET_OPEN_ITEM:				
				/**15 宠物技能书*/
				case PackageType.PET_SKILL_BOOK:				
				/**16 宠物技能绑定道具*/
				case PackageType.PET_SKILL_ITEM:				
				/**17 宠物忠诚食物*/
				case PackageType.PET_LOYAL_FOOD:				
				/**18 宠物资质丹药*/
				case PackageType.PET_TALENT_DRUG:				
				/**19 宠物洗练丹*/
				case PackageType.PET_WASH_DRUG:
				/**20 宠物融合幸运符*/
				case PackageType.PET_FUSE_GOODLUCK:
				/**21 宠物技能解绑符*/
				case PackageType.PET_SKILL_UNFASTEN:		
				/**36 场景道具*/
				case PackageType.SCENE_ITEMS:
				/**27 金钱袋*/
				case PackageType.MONEYPACKAGE:
				TipsManage.ShowItemTips(configID,isInShop,isFollow,stagePosition);
				break;
				/**23 装备*/
				case PackageType.EQUIP:
				if(contrast)
				{
					TipsManage.showCompareEquip(PackageType.EQUIP,configID,_data);
				}
				else
				{
					TipsManage.ShowItemMaxTips(configID,_data,isInShop,isFollow,stagePosition,isSelf,isReadRecord);
				}	
				break;
				/**22 宠物蛋*/
				case PackageType.PET_EGGS:	
				TipsManage.petEggTips(configID,_data,isInShop,isFollow,stagePosition,isShowEgg);
				break;
				/**33 宠物头盔*/
				case PackageType.PET_EQUIP:				
				TipsManage.ShowItemMaxTips(configID,_data,false,isFollow,stagePosition);
				break;
				default : 
				TipsManage.ShowItemTips(configID,isInShop,isFollow,stagePosition);
				break;				
				
			}

		}
		
		/**
		 * 隐藏tips
		 * 
		 */		
		public static function hideTips():void
		{
			ToolTips.hide();
		}
		
	
	}
}
